package com.markerhub.controller;

import com.markerhub.common.lang.Result;
import com.markerhub.service.AdminDashboardService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
@Slf4j
@RestController
@RequestMapping("/admin/dashboard")
public class AdminDashboardController {

    @Autowired
    private AdminDashboardService dashboardService;

    @GetMapping("/stats")
    public Result getDashboardStats() {
        try {
            Map<String, Object> stats = dashboardService.getStats();
            return Result.succ(stats);
        } catch (Exception e) {
            log.error("获取仪表盘统计数据失败", e);
            return Result.fail("获取统计数据失败");
        }
    }
}
